const itemID = require('../data/itemID.json');
const npcID = require('../data/npcID.json');
const skillID = require('../data/skillID.json');
const hitPileEventType = require('../data/hitPileEventType.json');

const getItemName = (arr) => {
    let res = '';
    for (const k in arr) {
        res += `${itemID[k]}x${arr[k]}[${k}] `;
    }
    return res.substring(0, res.length - 1);
}
const getOneItemName = (id) => {
    return itemID[id];
}

const getSkillName = (id) => {
    return skillID[id];
}

const getNpcName = (id) => {
    return npcID[id];
}

const getHitPileEventName = (arr) => {
    let res = '';
    for (let i = 0; i < arr.length; i++) {
        const data = arr[i];
        if (data.type == 1) {
            res += `${hitPileEventType[data.type]} 武学: ${getSkillName(data.number[0])}[${data.number[0]}]+${data.number[1]} `;
        } else {
            res += `${hitPileEventType[data.type]}x${data.number}[${data.type}] `;
        }
    }
    return res.substring(0, res.length - 1);
}

module.exports = {
    getOneItemName,
    getItemName,
    getSkillName,
    getNpcName,
    getHitPileEventName
}